import Vue from 'vue'
import Router from 'vue-router'

import Login from '@/views/login'
import Home from '@/views/home'
import Exam from '@/views/exam'
import Statistics from '@/views/statistics'
import Setting from '@/views/setting'

Vue.use(Router)

export const navRouter = [
  {
    path: 'exam', name: 'exam', component: Exam, meta: { title: '算数题在线练习' }
  },
  {
    path: 'statistics', name: 'statistics', component: Statistics, meta: { title: '成绩统计' }
  },
  {
    path: 'setting', name: 'setting', component: Setting, meta: { title: '难度设置' }
  }
]

export const constantRouterMap = [
  {
    path: '/login', name: 'login', component: Login
  },
  {
    path: '', name: 'home', redirect: 'exam', component: Home, children: navRouter
  },
  {
    path: '*',
    redirect: '/'
  }
]

export default new Router({
  // mode: 'history', // require service support (另外支持hash)
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
